package com.ncs.base.common.rule;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

public class PropertiesUtil2 {
	private static Logger log=LoggerFactory.getLogger(PropertiesUtil2.class);
	private static  Properties properties;
	private static final String name="application.yml";
	static {
		try {
			properties=new Properties();
			properties.load(new InputStreamReader(PropertiesUtil2.class.getClassLoader().getResourceAsStream(name), "utf-8"));
		} catch (UnsupportedEncodingException e) {
		} catch (IOException e) {
			log.error("IOException"+e);
		}
	}
	
	public static String  getValue(String key) {
		String value=properties.getProperty(key).trim();
		if(value==null) {
			return	null;
		}
		return value;
	}
	
	
	public static String  getValue(String key,String defaultvalue) {
		String value=properties.getProperty(key).trim();
		if(value==null) {
			value=defaultvalue;
		}
		return value;
	}
}
